package thread;



import com.sun.org.apache.bcel.internal.generic.NEW;
import org.apache.commons.lang3.StringUtils;
import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;

/**
 * @author ZhouJie
 * @date 2021-11-07 0:16
 */
public class ListTest {

    @Test
    public void test3(){
        System.out.println(StringUtils.isBlank("   "));
    }

    @Test
    public void test2(){
        List<Integer> list = new ArrayList<>();
        int i = 0;
        for (; i < 100; i++) {
            list.add(i);
        }
        list.parallelStream().forEach(System.out::println);


    }

    @Test
    public void test() throws InterruptedException {
        //CopyOnWriteArrayList<Integer> list = new CopyOnWriteArrayList<>();
        List<Integer> list = Collections.synchronizedList(new ArrayList<>());
        for (String s : Arrays.asList("线程一","线程二","线程三")){
            new Thread(()->{
                for (int i = 0; i < 100000; i++) {
                    list.add(i);
                }
            },s).start();
        }

        TimeUnit.SECONDS.sleep(10);
        System.out.println(list.size());
    }
}
